function validateDateFormat(value){
	var regex = /^([0-9]{4})-([0-1][0-9])-([0-3][0-9])$/;
	return regex.test(value);                                                                                                                                                                                          
}
function validateAddCustomerForm(){
	var isValid=true;
	
	if(document.addNewCustomerForm.buildingNumber.value == ""){
		document.getElementById("buildingNumber").style.display="block";
		isValid=false;
	} else{
		document.getElementById("buildingNumber").style.display="none";
	}	
	if(document.addNewCustomerForm.street.value == ""){
		document.getElementById("street").style.display="block";
		isValid=false;
	} else{
		document.getElementById("street").style.display="none";
	}	
	if(document.addNewCustomerForm.city.value == ""){
		document.getElementById("city").style.display="block";
		isValid=false;
	} else{
		document.getElementById("city").style.display="none";
	}	
	if(document.addNewCustomerForm.state.value == ""){
		document.getElementById("state").style.display="block";
		isValid=false;
	} else{
		document.getElementById("state").style.display="none";
	}	
	if(document.addNewCustomerForm.zipCode.value == ""){
		document.getElementById("zipCode").style.display="block";
		isValid=false;
	} else{
		document.getElementById("zipCode").style.display="none";
	}	
	if(document.addNewCustomerForm.country.value == ""){
		document.getElementById("country").style.display="block";
		isValid=false;
	} else{
		document.getElementById("country").style.display="none";
	}	
	if(document.addNewCustomerForm.firstName.value == ""){
		document.getElementById("firstName").style.display="block";
		isValid=false;
	} else{
		document.getElementById("firstName").style.display="none";
	}	
	if(document.addNewCustomerForm.lastName.value == ""){
		document.getElementById("lastName").style.display="block";
		isValid=false;
	} else{
		document.getElementById("lastName").style.display="none";
	}
	if(document.addNewCustomerForm.gender.value == "" || (document.addNewCustomerForm.gender.value != "MALE" && document.addNewCustomerForm.gender.value != "FEMALE")){
		document.getElementById("gender").style.display="block";
		isValid=false;
	} else{
		document.getElementById("gender").style.display="none";
	}	
	if(document.addNewCustomerForm.countryCode.value == ""){
		document.getElementById("countryCode").style.display="block";
		isValid=false;
	} else{
		document.getElementById("countryCode").style.display="none";
	}	
	if(document.addNewCustomerForm.number.value == ""){
		document.getElementById("number").style.display="block";
		isValid=false;
	} else{
		document.getElementById("number").style.display="none";
	}	
	if(document.addNewCustomerForm.email.value == ""){
		document.getElementById("email").style.display="block";
		isValid=false;
	} else{
		document.getElementById("email").style.display="none";
	}	
	if(document.addNewCustomerForm.birthDate.value == "" || !validateDateFormat(document.addNewCustomerForm.birthDate.value)){
		document.getElementById("birthDate").style.display="block";
		isValid=false;
	} else{
		document.getElementById("birthDate").style.display="none";
	}
	if(isValid){
		document.addNewCustomerForm.submit();
	}
}
function validateAddCreditCardForm(){
	var isValid=true;
		
	if(document.addNewCreditCardForm.nameOnCard.value == ""){
		document.getElementById("nameOnCard").style.display="block";
		isValid=false;
	} else{
		document.getElementById("nameOnCard").style.display="none";
	}	
	if(document.addNewCreditCardForm.cardNumber.value == "" || isNaN(document.addNewCreditCardForm.cardNumber.value)){
		document.getElementById("cardNumber").style.display="block";
		isValid=false;
	} else{
		document.getElementById("cardNumber").style.display="none";
	}	
	if(document.addNewCreditCardForm.securityCode.value == "" || isNaN(document.addNewCreditCardForm.securityCode.value)){
		document.getElementById("securityCode").style.display="block";
		isValid=false;
	} else{
		document.getElementById("securityCode").style.display="none";
	}		
	if(document.addNewCreditCardForm.type.value == "" || (document.addNewCreditCardForm.type.value != "VISA" && document.addNewCreditCardForm.type.value != "MASTER_CARD")){
		document.getElementById("type").style.display="block";
		isValid=false;
	} else{
		document.getElementById("type").style.display="none";
	}	
	if(document.addNewCreditCardForm.expirationDate.value == "" || !validateDateFormat(document.addNewCreditCardForm.expirationDate.value)){
		document.getElementById("expirationDate").style.display="block";
		isValid=false;
	} else{
		document.getElementById("expirationDate").style.display="none";
	}
	if(isValid){
		document.addNewCreditCardForm.submit();
	}
}